module AboutYou
  module SDK
    module Model
      ###
      # This class represents a FacetCounts model.
      #
      # author:: Collins GmbH & Co KG
      ###
      class FacetCounts
        # The group_id of the facetcounts
        attr_accessor :group_id
        # an array of facetcount objects
        attr_accessor :facet_count_list
        # the cont of the products
        attr_accessor :product_count_total
        # the count of the products without facets
        attr_accessor :product_count_without_any_facet
        # the count of the procuts with other facets
        attr_accessor :product_count_with_other_facet

        ###
        # the Constructor for the facetcounts class
        #
        # * *Args*    :
        #   - +product_count_total+ -> the total productcount
        #   - +product_count_with_other_facet+ -> the productcount without any facets
        #   - +product_count_without_any_facet+ -> the productcount with other facets
        #
        # * *Returns* :
        #   - Instance of AboutYou::SDK::Model::FacetCounts
        ###
        def initialize(
            product_count_total,
            product_count_with_other_facet,
            product_count_without_any_facet
          )
          self.product_count_total             = product_count_total
          self.product_count_with_other_facet  = product_count_with_other_facet
          self.product_count_without_any_facet = product_count_without_any_facet
        end

        ###
        # This method is used for creating an instance of this class by a json_object.
        #
        # * *Args*    :
        #   - +group_id+ -> the groupId of the facetcounts
        #   - +json_object+ -> the jsonObject received from the api
        #   - +facet_count_list+ -> a list of facetcount objects
        #
        # * *Returns* :
        #   - Instance of AboutYou::SDK::Model::FacetCounts
        ###
        def self.create_from_json(group_id, json_object, facet_count_list)
          facet_counts = new(
            json_object['total'],
            json_object['other'],
            json_object['missing']
          )
          facet_counts.group_id = group_id
          facet_counts.facet_count_list = facet_count_list

          facet_counts
        end
      end
    end
  end
end
